package com.zhentao.config;

import com.alibaba.fastjson.JSON;
import com.zhentao.dto.Dto;
import com.zhentao.mapper.EmpMapper;
import com.zhentao.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.KafkaListeners;

@Configuration
public class Lisener {
    @Autowired
    private EmpMapper empMapper;
    @KafkaListener(topicPattern = "topic1")
    public void a(String msg){
        Dto dto = JSON.parseObject(msg, Dto.class);
        System.err.println(dto);
        Emp emp = empMapper.selectById(dto.getEid());
        emp.setStatus(dto.getStatus());
        empMapper.updateById(emp);
    }
}
